<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=utf-8" %>
<jsp:useBean  id="myCar" class="chen.toolbean.ShopCar" scope="session" />
<c:set value="0" var="total" scope="page" />
<table border="1" width="550" rules="none" cellspacing="0" cellpadding="0" >
   <tr height="50"><td colspan="5" align="center">购买的商品如下</td></tr>
   <tr align="center" height="30" bgcolor="lightgrey">
         <td></td>
	 <td width="25%">名称</td>
	 <td>价格(元/斤)</td>
	 <td>数量</td>
	 <td>总价(元)</td>
	 <td>移除(-1/次)</td>
    </tr>
    <c:set var="total" value="0" scope="page"/>
    <c:choose>
        <c:when test="${empty(myCar.buylist)}">
    <tr height="100"><td colspan="5" align="center">您的购物车为空！</td></tr>
        </c:when>
        <c:otherwise>
        <c:forEach var="single" items="${myCar.buylist}">          
         <tr align="center" height="50">
         <td><img src= "img/${single.img}" height="160"  width="220" hspace="20" vspace="10"></td>
         <td>${single.name}</td>
         <td>${single.price}</td>
         <td>${single.num}</td>
         <c:set var="money" value="${single.price*single.num}"/>
         <td><fmt:formatNumber minFractionDigits="2"  value="${money}" /></td>
         <td><a href="Docar?action=remove&name=${single.name}">移除</a>
         </td>
       </tr>
       <c:set var="total" value="${total+money}"/>
       </c:forEach>
    </c:otherwise>
   </c:choose>
   <tr height="50" align="center"><td colspan="5">应付金额：<fmt:formatNumber minFractionDigits="2" value="${total}"/></td></tr>
   <tr height="50" align="center">
	<td colspan="2"><a href="show.jsp">继续购物</a></td>
	<td colspan="3"><a href="Docar?action=clear">清空购物车</a></td>
   </tr>
</table>
    